< previous page page_122 next page >

Page 122
Because the Checked property can only be True or False, the preceding code makes nice use of some Boolean logic with the Not keyword. Not represents the opposite of a Boolean value, so Not mnuOptionsText.Checked returns the opposite of the current value of the Checked property of mnuOptions. This process is known as "toggling" a Boolean value. At any point in the program code, the state of the Checked property indicates whether the user wants the document to be composed of plain text.
Of course, you can set a menu item's Checked property at designtime if you want that item to be checked when the program begins.
CAUTION
You cannot set the Checked property to True for an item on the menu bar (top menu level). Doing so results in an error.

Other Properties
You might have noticed two other items in the Menu Editor. These items specify the value of the NegotiatePosition and WindowList properties of the menu item. The NegotiatePosition property specifies whether and where the menu item of your application is displayed when an embedded object on a form is active and its menu is shown (for example, if your application has an instance of Word embedded for modifying a document). If the NegotiatePosition property is 0, your menu is not displayed while the object is active. If the property is not 0, your menu item is displayed to the left of, in the middle of, or to the right of the object's menu (property settings of 1, 2, or 3, respectively). The WindowList property specifies whether the current menu should maintain a list of active MDI child forms. When this property is True, items are automatically appended to the menu as child forms are opened, and removed when the corresponding child forms are closed. You learn about this topic in more detail in Chapter 17, "Multiple Document Interface Applications."
Creating Pop-Up Menus
So far, the discussion of menus has looked at the menu bar that appears along the top of the form. Visual Basic also supports pop-up menus in your programs. A pop-up menu is a small menu that appears somewhere on your form in response to a program event.
Pop-up menus often are used to handle operations or options related to a specific area of the form (see Figure 6.10)for example, a format pop-up menu for a text field that lets you change the font or font attributes of the field. You can find such context-sensitive menus in many of the latest generation of Windows programs, including Visual Basic itself.
When a pop-up menu is invoked, usually by right-clicking an object with the mouse, the menu appears onscreen near the current mouse pointer location. The user then makes a selection from the menu. After the selection is made, the menu disappears from the screen.

 
< previous page page_122 next page >